package com.String;

import java.util.Scanner;

/*
判断字符串包含数字字符的个数
*/
public class Demo04 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串用来判断包含数字的个数：");
        String str = sc.next();
        char[] c = str.toCharArray();
        int count = 0;//用来统计数字的个数
        for (int i = 0; i < c.length; i++) {
            if (c[i] <= '9' && c[i] >= '0') {
                count++;
            }
        }
        System.out.println("字符串包含数字有" + count + "个！");
    }
}
